/*
 * logic.h
 *
 * Created: 2012.11.23. 19:30:21
 *  Author: some00
 */ 


#ifndef LOGIC_H_
#define LOGIC_H_

#define DELTA_BRIGHTNESS 5
#define DELTA_CONTRAST 5
#define DELTA_VOLUME 5
#define BUFFER_SIZE 10

#include <avr/interrupt.h>

void InitLogic();

typedef enum buttonType
{
	button_on_off,
	button_mute,
	button_1,
	button_2,
	button_3,
	button_4,
	button_5,
	button_6,
	button_7,
	button_8,
	button_9,
	button_i,
	button_0,
	button_epg,
	button_vol_up,
	button_vol_down,
	button_menu,
	button_txt,
	button_p_plus,
	button_p_minus,
	button_up,
	button_left,
	button_right,
	button_down,
	button_ok,
	button_exit,
	button_opt,
	button_red,
	button_green,
	button_yellow,
	button_blue,
	button_msg,
	button_tv_stb,
	button_unknown,
	button_tv_r,
	
	repeat,
	invalid
}Button;

typedef struct OperationS
{
	char OpType;						//read-write
	char FlashType;						//edid-ddc
	int address;						//address
	int value;							//value
	void (*callback)(OperationS);		//callback function pointer
	Button button;
}Operation;

Operation nextOp(Operation last);

void callBackFunction(Operation op);
int repeatTypeButton(Button b);


typedef struct Buffer_S
{
	Operation data[BUFFER_SIZE];
	int write;
	int read;
}Buffer;

//returns	0:FAIL = FULL
//			1:SUCCES
int bufferAdd(Operation op);

//returns	0:FAIL = EMPTY
//			1:SUCCES
int bufferGet(Operation *op);

void AddUartButton();

#endif /* LOGIC_H_ */